const path = require('path');

// 设置模块路径
const rootDir = path.join(__dirname, '..');
process.chdir(rootDir);

// 动态导入ES模块
async function runImport() {
  try {
    console.log('Starting data import...');
    
    // 使用动态导入
    const { importAllDataFromCsv } = await import('../lib/excel-to-sqlite-importer.js');
    
    const result = await importAllDataFromCsv();
    console.log('Import completed:', result);
    
    process.exit(result.success ? 0 : 1);
  } catch (error) {
    console.error('Import failed:', error);
    process.exit(1);
  }
}

runImport(); 